import Vue from 'vue';
import VueAxios from 'vue-axios';

import 'bootstrap/dist/js/bootstrap.min.js'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'canvg/dist/browser/canvg.min.js'

import Element from 'element-ui';

import './import';


import RegisterGlobalComponents from '@/components/index';
import * as urls from '@/config/env';

import website from '@/config/website';
import crudCommon from '@/mixins/crud';
// import breadcrumb from '@/breadcrumb';
import installPlugins from '@/plugins/index';
import i18n from '@/lang';
import router from '@/router/router';
import axios from '@/router/axios';
import store from '@/store';

import { loadStyle } from '@/util/util'

import { iconfontUrl, iconfontVersion } from '@/config/env';

import { directive , clearDirective } from './directive';

// 注册全局组件
RegisterGlobalComponents(Vue);

// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key];
});


// 注册全局crud驱动
window.$crudCommon = crudCommon;


// 加载website
Vue.prototype.website = website;

// 注入全局指令
Vue.use(directive);

// 加载Vue拓展
installPlugins(Vue);
// Vue.use(breadcrumb);

// 清除Avue自带的权限校验指令
clearDirective('permission' , window.AVUE.Crud , true);
// 重写Avue-crud getPermission方法
window.AVUE.Crud.methods.getPermission = function(key, row, index){
  return {key, row, index};
}
Vue.use(window.AVUE, {
  size: 'small',
  tableSize: 'small',
  calcHeight: 148,
  i18n: (key, value) => i18n.t(key, value)
});



Vue.use(router);
Vue.use(VueAxios, axios);

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
});


// 动态加载阿里云字体库
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele));
});

export default {
  router,
  store,
  i18n
}